#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N = 1e3 + 10;
int nums[N][N], sum[N][N];
int n, m, q;
int x1, y11, x2, y2;
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> nums[i][j];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + nums[i][j];
        }
    }
    while (q--)
    {
        cin >> x1 >> y11 >> x2 >> y2;
        cout << sum[x2][y2] - sum[x2][y11 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y11 - 1] << endl;
    }
    return 0;
}